package playerData;

import gui.MainFrame;
import java.awt.Image;

public class Player {
    
    private final Image playerLeft, playerRight;
    private int x, y;
    private final String name;
    private int hp, playerNr;
    private boolean dead;
    
    public Player(Image playerLeft, Image playerRight, int x, int y, String name, int playerNr) {
        this.playerLeft = playerLeft;
        this.playerRight = playerRight;
        this.x = y;
        this.y = y;
        this.name = name;
        hp = 100;
        dead = false;
        this.playerNr = playerNr;
    }
    
    public Image getPlayerLeft() {
        return playerLeft;
    }
    
    public Image getPlayerRight() {
        return playerRight;
    }
    
    public int getX() {
        return x;
    }
    
    public int getY() {
        return y;
    }
    
    public String getName() {
        return name;
    }
    
    public void receiveDamage(int damage) {
        if ((hp -= damage) <= 0) {
            hp = 0;
            dead = true;
        }
        
        if (playerNr == 1) {
            MainFrame.player1HP.setValue(hp);
        } else {
            MainFrame.player2HP.setValue(hp);
        }
    }
    
    public boolean getDead(){
        return dead;
    }
}
